allos.dev logo

14 Dec 2025 ~ 2 min read

The Source Code Rabbit-hole (Inspired by NPM)


Background

I want to create a simple email viewer. That’s bec I’m using MailKit (via C# / Nuget) to download the email messages from my email server.

So, I will just accept that dependency, bec it is Nuget & feels official. So that is a rabbit-hole I won’t travel down.

NPM Rabbit-hole

I look around for a library that allows me to view the eml (email data format) files as HTML.

Cool, I find a node package which will convert eml to html. eml-parser via NPM.

View Source Code (yes, it’s JS)

You can view the bulk of the source code for this parser, here (also on the NPM site).

That doesn’t look terrible. Ok, let’s take a look at the eml-parser’s dependencies shown here (on NPM site). There are only 7 dependencies, so it can’t be that bad, right?

EML to PDF

Oh, there’s one that allows you to convert from EML directly to PDF. Let’s take a look, here (again on NPM site).

Deprecated!

Well, that package has a warning that it is deprecated and you should use puppeteer now instead.

Ignore It & Try Sample

Ok, I got it. For now I say, “forget it, let’s try a sample”.

Create Node Project
  1. create a quick node project
  2. install the eml-parser
  3. copy paste some sample code & voila!!

Here’s the entire program that takes test.eml and converts it to PDF & HTML.

console.log(`I'm running...`);

const  EmlParser = require('eml-parser');
 const  fs = require('fs');
 
 let  emailFile = fs.createReadStream('./test.eml');

new  EmlParser(emailFile).convertEmailToStream('pdf')
.then(stream  => {
   stream.pipe(fs.createWriteStream(emailFile.path + '.pdf'));
})
.catch(err  => {
   console.log(err);
});

new EmlParser(fs.createReadStream('./test.eml'))
.getEmailAsHtml()
.then(htmlString  => {
	fs.writeFileSync('abc.html',htmlString)	;
})
.catch(err  => {
	console.log(err);
})

It works great. It’s easy. I have a nice little converter so I can just simply view the email messages that I retrieve from my server. No one controls me!! 🤓

Oh, let’s take a look at the node_modules that were installed for this little program:

4de15e10-152f-42ca-9918-cadb8c93977c-image.png

dizzy bear


Headshot of Maxi Ferreira

Hi, I'm Roger. I'm a software developer based in Dayton, Ohio. You can follow me on LinkedIn or Twitter, see some of my work on GitHub, or read more about my Open Source password manager (and try it out at C'YaPass web). C'YaPass doesn't store your passwords anywhere (it generates them every time).